package com.example.subject10mvn.controller;

import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class Test {
    @PostMapping("test")
    public Map<Object, Object> postData(HttpServletRequest request, @RequestBody String data){
        System.out.println(request.getRemoteAddr()+"   "+new Date());
        System.out.println(data);
        Map<Object, Object> map = new HashMap<>();
        map.put("resultCode",200);
        return map;
    }
    @GetMapping("test")
    public String getData(HttpServletRequest request){
        System.out.println(request.getRemoteAddr()+"   "+new Date());
        return "ok";
    }
    @PutMapping("test")
    public Map<Object, Object> putData(HttpServletRequest request, @RequestBody List<Map<Object, Object>> data){
        System.out.println(request.getRemoteAddr()+"   "+new Date());
        System.out.println(data);
        Map<Object, Object> map = new HashMap<>();
        map.put("resultCode",200);
        return map;
    }
}
